package com.dragon.sso.config.base;

import com.dragon.sso.config.LDAPConfiguration;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "oauth2")
@EnableConfigurationProperties({LDAPConfiguration.class
        , Registration.class})
public class AuthServerConfiguration {

    @NestedConfigurationProperty
    private LDAPConfiguration ldap = new LDAPConfiguration();

    @NestedConfigurationProperty
    private List<Registration> registrations = new ArrayList<>();

    private KeyStore keyStore = new KeyStore();

    public KeyStore getKeyStore() {
        return keyStore;
    }

    /** Keystore configuration for signing and verifying JWT tokens. */
    public static class KeyStore {
        // name of the keystore in the classpath
        private String name = "tls/keystore.p12";
        // password used to access the key
        private String password = "password";
        // name of the alias to fetch
        private String alias = "selfsigned";

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getAlias() {
            return alias;
        }

        public void setAlias(String alias) {
            this.alias = alias;
        }
    }

//    @NestedConfigurationProperty
//    private MockUserConfiguration mockUser = new MockUserConfiguration();

}
